<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>过滤器</title>
  <!-- 开发环境版本，包含了有帮助的命令行警告 -->
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.js"></script>
</head>
<body>
<div id="demo">
  {{date}}<br>
  {{date | dateString('HH:mm:ss')}}<br>
  {{date | dateString}}<br>

</div>

<script type="text/javascript">
  // 过滤器
  Vue.filter('dateString',function (value,formstr){
    console.log(value);
    var value1 = moment(value).format(formstr || 'YYYY-MM-DD HH:mm:ss');
    return value1;
  });
  const vm = new Vue({
    el: '#demo',
    data:{
      date:new Date()
    }
  });

</script>
</body>
</html>